/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://TODOwww.gnu.org/copyleft/gpl.html
 */
package l1j.server.server;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 循環公告
 * @return bymca
 */
public class GetNowTime {
	public static int GetNowDay() {
		final Calendar rightNow = Calendar.getInstance();//TODO 取得預設月曆物件
		int nowDay;
		nowDay = rightNow.get(Calendar.DATE);//TODO 取得今日之值
		return nowDay;//TODO 傳回取得今日之值
	}

	//opqlo
	public static int GetNowHour() {//24小時制
		final Calendar rightNow = Calendar.getInstance();//TODO 取得預設月曆物件
		int nowHour;
		nowHour = rightNow.get(Calendar.HOUR_OF_DAY);//TODO 取得此時之值
		return nowHour;//TODO 傳回取得此時之值
	}

	public static int GetNowMinute() {
		final Calendar rightNow = Calendar.getInstance();//TODO 取得預設月曆物件
		int nowMinute;
		nowMinute = rightNow.get(Calendar.MINUTE);//TODO 取得此分之值
		return nowMinute;//TODO 傳回取得此分之值
	}
	public static int GetNowMonth() {
		final Calendar rightNow = Calendar.getInstance();//TODO 取得預設月曆物件
		int nowMonth;
		nowMonth = rightNow.get(Calendar.MONTH);//TODO 取得現月之值
		return nowMonth;//TODO 傳回取得現月之值
	}
	public static int GetNowSecond() {
		final Calendar rightNow = Calendar.getInstance();//TODO 取得預設月曆物件
		int nowSecond;
		nowSecond = rightNow.get(Calendar.SECOND);//TODO 取得此秒之值
		return nowSecond;//TODO 傳回取得此秒之值
	}

	public static int GetNowWeek() {//opqlo
		// 週日=0、週一=1、週二=2、週三=3、週四=4、週五=5、週六=6

		final Calendar rightNow = Calendar.getInstance(); // 取得預設月曆物件
		int nowWeek;
		nowWeek = rightNow.get(Calendar.DAY_OF_WEEK); // 取得今日星期之值
		return nowWeek - 1; // 傳回取得今日星期之值
	}

	public static int GetNowYear() {
		final Calendar rightNow = Calendar.getInstance();//TODO 取得預設月曆物件
		int nowYear;
		nowYear = rightNow.get(Calendar.YEAR);//TODO 取得現年之值
		return nowYear;//TODO 傳回取得現年之值
	}
	
	public static String GetFormatDate(){
		 //取得時間物件，預設為現在時間
		final Date date = Calendar.getInstance().getTime();

	    //定義日期格式
	   final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

	    //將日期轉換成指定格式的字串
	    return sdf.format(date);
	}
}
